package com.xianbeiying.app.ckgl.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.xianbeiying.app.ckgl.R;

import java.util.ArrayList;

/**
 * 种植作物数据适配
 */
public class PlantCropAdapter extends BaseAdapter{
    private Context context;
    private ArrayList<String> growPlant;
    private ArrayList<Integer> growNumber;
    public PlantCropAdapter(Context context,ArrayList<String> growPlant,ArrayList<Integer> growNumber){
        this.context = context;
        this.growPlant=growPlant;
        this.growNumber=growNumber;
    }
    @Override
    public int getCount() {
        return growPlant.size();
    }

    @Override
    public Object getItem(int position) {
        return getItem(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.item_date_tiem, parent, false);
            holder = new ViewHolder();
            holder.tv_multe_name=(TextView)convertView.findViewById(R.id.tv_multe_name);
            holder.tv_multe_time=(TextView) convertView.findViewById(R.id.tv_multe_time);
            convertView.setTag(holder);
        }else{
            holder = (ViewHolder) convertView.getTag();
        }
        holder.tv_multe_name.setText(growPlant.get(position));
        holder.tv_multe_time.setText(growNumber.get(position)+"天");
        return convertView;
    }
    private class ViewHolder{
       TextView tv_multe_name;
       TextView tv_multe_time;
    }
}
